/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Administrateur
 */
@Entity
@Table(name = "client")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Client.findAll", query = "SELECT c FROM Client c"),
    @NamedQuery(name = "Client.findByIdclient", query = "SELECT c FROM Client c WHERE c.idclient = :idclient"),
    @NamedQuery(name = "Client.findByNom", query = "SELECT c FROM Client c WHERE c.nom = :nom"),
    @NamedQuery(name = "Client.findByTelephone", query = "SELECT c FROM Client c WHERE c.telephone = :telephone"),
    @NamedQuery(name = "Client.findByIdType", query = "SELECT c FROM Client c WHERE c.idType = :idType"),
    @NamedQuery(name = "Client.findByDateNaissance", query = "SELECT c FROM Client c WHERE c.dateNaissance = :dateNaissance"),
    @NamedQuery(name = "Client.findByAdresse", query = "SELECT c FROM Client c WHERE c.adresse = :adresse"),
    @NamedQuery(name = "Client.findByEmail", query = "SELECT c FROM Client c WHERE c.email = :email"),
    @NamedQuery(name = "Client.findByUrl", query = "SELECT c FROM Client c WHERE c.url = :url"),
    @NamedQuery(name = "Client.findByAdresseComp", query = "SELECT c FROM Client c WHERE c.adresseComp = :adresseComp"),
    @NamedQuery(name = "Client.findByDatePremierAchat", query = "SELECT c FROM Client c WHERE c.datePremierAchat = :datePremierAchat"),
    @NamedQuery(name = "Client.findByDateDernierAchat", query = "SELECT c FROM Client c WHERE c.dateDernierAchat = :dateDernierAchat"),
    @NamedQuery(name = "Client.findByMontantAccumule", query = "SELECT c FROM Client c WHERE c.montantAccumule = :montantAccumule"),
    @NamedQuery(name = "Client.findByNombreAchats", query = "SELECT c FROM Client c WHERE c.nombreAchats = :nombreAchats")})
public class Client implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "idclient")
    private Integer idclient;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "nom")
    private String nom;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "telephone")
    private String telephone;
    @Basic(optional = false)
    @NotNull
    @Column(name = "idType")
    private int idType;
    @Basic(optional = false)
    @NotNull
    @Column(name = "date_naissance")
    @Temporal(TemporalType.DATE)
    private Date dateNaissance;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 200)
    @Column(name = "adresse")
    private String adresse;
    // @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "email")
    private String email;
    @Size(max = 45)
    @Column(name = "url")
    private String url;
    @Size(max = 200)
    @Column(name = "adresse_comp")
    private String adresseComp;
    @Column(name = "date_premier_achat")
    @Temporal(TemporalType.DATE)
    private Date datePremierAchat;
    @Column(name = "date_dernier_achat")
    @Temporal(TemporalType.DATE)
    private Date dateDernierAchat;
    @Basic(optional = false)
    @NotNull
    @Column(name = "montant_accumule")
    private double montantAccumule;
    @Basic(optional = false)
    @NotNull
    @Column(name = "nombre_achats")
    private int nombreAchats;
    @JoinColumn(name = "idPays", referencedColumnName = "idpays_client")
    @ManyToOne(optional = false)
    private PaysClient idPays;
    @JoinColumn(name = "idLangue", referencedColumnName = "idlangue")
    @ManyToOne(optional = false)
    private Langue idLangue;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idclient")
    private Collection<Commande> commandeCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idClient")
    private Collection<Utilisateur> utilisateurCollection;

    public Client() {
    }

    public Client(Integer idclient) {
        this.idclient = idclient;
    }

    public Client(Integer idclient, String nom, String telephone, int idType, Date dateNaissance, String adresse, String email, double montantAccumule, int nombreAchats) {
        this.idclient = idclient;
        this.nom = nom;
        this.telephone = telephone;
        this.idType = idType;
        this.dateNaissance = dateNaissance;
        this.adresse = adresse;
        this.email = email;
        this.montantAccumule = montantAccumule;
        this.nombreAchats = nombreAchats;
    }

    public Integer getIdclient() {
        return idclient;
    }

    public void setIdclient(Integer idclient) {
        this.idclient = idclient;
    }

    public String getNom() {
        return nom;
    }

    public void setNom(String nom) {
        this.nom = nom;
    }

    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    public int getIdType() {
        return idType;
    }

    public void setIdType(int idType) {
        this.idType = idType;
    }

    public Date getDateNaissance() {
        return dateNaissance;
    }

    public void setDateNaissance(Date dateNaissance) {
        this.dateNaissance = dateNaissance;
    }

    public String getAdresse() {
        return adresse;
    }

    public void setAdresse(String adresse) {
        this.adresse = adresse;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getAdresseComp() {
        return adresseComp;
    }

    public void setAdresseComp(String adresseComp) {
        this.adresseComp = adresseComp;
    }

    public Date getDatePremierAchat() {
        return datePremierAchat;
    }

    public void setDatePremierAchat(Date datePremierAchat) {
        this.datePremierAchat = datePremierAchat;
    }

    public Date getDateDernierAchat() {
        return dateDernierAchat;
    }

    public void setDateDernierAchat(Date dateDernierAchat) {
        this.dateDernierAchat = dateDernierAchat;
    }

    public double getMontantAccumule() {
        return montantAccumule;
    }

    public void setMontantAccumule(double montantAccumule) {
        this.montantAccumule = montantAccumule;
    }

    public int getNombreAchats() {
        return nombreAchats;
    }

    public void setNombreAchats(int nombreAchats) {
        this.nombreAchats = nombreAchats;
    }

    public PaysClient getIdPays() {
        return idPays;
    }

    public void setIdPays(PaysClient idPays) {
        this.idPays = idPays;
    }

    public Langue getIdLangue() {
        return idLangue;
    }

    public void setIdLangue(Langue idLangue) {
        this.idLangue = idLangue;
    }

    @XmlTransient
    public Collection<Commande> getCommandeCollection() {
        return commandeCollection;
    }

    public void setCommandeCollection(Collection<Commande> commandeCollection) {
        this.commandeCollection = commandeCollection;
    }

    @XmlTransient
    public Collection<Utilisateur> getUtilisateurCollection() {
        return utilisateurCollection;
    }

    public void setUtilisateurCollection(Collection<Utilisateur> utilisateurCollection) {
        this.utilisateurCollection = utilisateurCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idclient != null ? idclient.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Client)) {
            return false;
        }
        Client other = (Client) object;
        if ((this.idclient == null && other.idclient != null) || (this.idclient != null && !this.idclient.equals(other.idclient))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Client[ idclient=" + idclient + " ]";
    }
    
}
